package com.eugene.ui.util;
//Deprecated

import java.util.ArrayList;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;

import com.eugene.entity.CommonEntity;
import com.eugene.enums.EMarketVariableType;

public class ImageAndColorProvider extends LabelProvider
	implements ITableLabelProvider,IColorProvider{
	
	private TableViewer tableViewer;
	private Color gray = new Color(Display.getCurrent(), 229, 232, 235);
	

	public ImageAndColorProvider(TableViewer tableViewer) {
		this.tableViewer = tableViewer;
	}
	public String getColumnText(Object element, int columnIndex) {
		CommonEntity person = (CommonEntity) element;
		switch (columnIndex) {
		case 0:
			return person.getBaseDate().toString();
		case 1:
			return person.getEtyId();
		case 2:
			return person.getMaturity().toString();
		case 3:
			return ((Double)person.getPrimaryValue()).toString();
		default:
			throw new RuntimeException("Should not happen");
		}

//		return ((String) element) + columnIndex;
	}
	@Override
	public Image getColumnImage(Object element, int columnIndex) {
		// In case you don't like image just return null here
//		if (columnIndex == 3) {
//			if (((Person) element).isMarried()) {
//				return CHECKED;
//			} else {
//				return UNCHECKED;
//			}
//		}
		return null;
	}

	public Color getBackground(Object element) {
		ArrayList list = (ArrayList) this.tableViewer.getInput();
		int index = list.indexOf(element);
		if ((index % 2) == 0) {
			return gray;
		} else {
			return null;
		}
	}

	public Color getForeground(Object element) {
		return null;
	}
 }

